<?
require("config.php");

$location_status .= "| Edit";
$menuname = NULL;
$menutarget = NULL;

if (NULL!=$action){

	if ($Picture_name=="" || $Picture_name==NULL) $Picture_name=$old_Picture;

	if ($remove_Picture=="ture") $Picture_name=NULL;

	$Date = "$Year-$Month-$Day";

   $field = array(
	"code", 
	"subject", 
	"mydate", 
	"details",
    "status",
	"publish_date",
	"picture", "order_index",
	);

   $content = array(
	$Code,
	$Subject,
	$myDate,
	$Details,
	$Status,
	"$myYear-$myMonth-$myDay",
	$Picture_name, $order_index,
	);

	$exp = "id=$id";

   myUpdate($table,$field,$content,$exp);

	$dir = "$table/";

	myUpload($Picture,$Picture_name,$dir);


   header("location:" . $rela_path . "share/msg.php?v=312");

   exit();

}else{

  if (!checkRecord($table,$id)){

	header("location:" . $rela_path . "share/msg.php?v=9002");

	exit();
  
  }

}


$Query = "SELECT 
	code, 
	subject, 
	details,
    status,
	publish_date,
	picture,
	mydate, order_index
FROM $table WHERE id=$id LIMIT 1";

$r=myQuery($Query);

$Code=$r[0][0];
$Subject=$r[0][1];
$Details=$r[0][2];
$Status=$r[0][3];
$Publish_date=$r[0][4];
$Picture=$r[0][5];
$Date=$r[0][6];
$order_index=$r[0][7];
require($rela_path . "inc/header.php");
require($rela_path . "bin/date.php");

?>



<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="action" type="hidden" value="edit">
<input name="Code" type="hidden" value="<?print($Code)?>">
<input name="old_Picture" type="hidden" value="<?print($Picture)?>">




<table width="95%" border="0" align="center">
  <tr> 
      <td valign="top"> <table border="0" cellspacing="5" cellpadding="1">
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Code : </td>
            <td><?print($Code)?></td>
          </tr>
          <tr> 
            <td class="tdheader">Subject :</td>
            <td><input type="text" class="text" name="Subject" size="56" value="<?echo $Subject?>"></td>
          </tr>

          <tr> 
            <td class="tdheader">Date :</td>
            <td><input type="text" class="text" name="myDate" size="56" value="<?echo $Date?>"></td>
          </tr>


          <tr> 
            <td class="tdheader">Publish :</td>
            <td> 
          <?

$sourceData = array(
  "Yes",
  "No",
  );

$boxName="Status";

$value=$Status;

FFPCheckBox("Status",$Status,$sourceData,$sourceLabel);

?>          </tr>
          <tr> 
            <td class="tdheader">Publishing Date : </td>
            <td><?print(FFPtime(date($Publish_date)))?></td>
          </tr>
          <tr> 
            <td class="tdheader">Details : </td>
            <td><textarea class="text" name="Details" cols="55" rows="20"><?echo $Details?></textarea></td>
          </tr>
          <tr>
            <td class="tdheader">Order :</td>
            <td><input name="order_index" type="text" class="text" id="order_index" value="<?=$order_index?>" size="5" /></td>
          </tr>
          <tr>
            <td>Picture :</td>
            <td>
              <?loadImage($Picture,$rela_path . $PIC_DIR. $table . "/")?>
              <?removeImage($Picture,"remove_Picture")?>
              <input type="file" class="text" name="Picture" size="45"></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input name="image" type="image" onClick="Redirect('menu.php',1);return false;" src="../../images/bt_cancel.gif"> 
              <input name="image" type="image" src="../../images/bt_save.gif">            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table></td>

  </tr>
</table>
<br>
<br>
<br>


</form>

<?
require($rela_path . "inc/footer.php");
?>
